import request from "@utils/request";
import taskData from './data.json';

const API = {
  PROGRAMMATIC_CREATE_AD: '/tt-programmatic-create/programmaticCreateAd', // 程序化创建广告
  GET_TASK_DETAILS: '/tt-create-ad-task/getTaskDetails', // 获取任务详情
  CANCEL_SUBMIT_TASK: '/tt-create-ad-task/cancelSubmitTask', // 单个或批量取消提交定时任务
  DEL_SUBMIT_TASK: '/tt-create-ad-task/delSubmitTask', // 删除定时任务
  CHECK_TASK_STATUS: '/tt-create-ad-task/checkTaskStatus', // 查看任务审核状态
};

/**
 * @description 程序化创建广告
 * @description 详细参数请查阅：http://192.168.0.170:19999/api/doc.html#/%E5%A4%B4%E6%9D%A1%E5%B9%B3%E5%8F%B0%E6%A8%A1%E5%9D%97/%E5%A4%B4%E6%9D%A1%E7%A8%8B%E5%BA%8F%E5%8C%96%E5%88%9B%E5%BB%BA%E6%A8%A1%E5%9D%97/programmaticCreateAdUsingPOST
 * @author fengjin
 * @date 2021-11-09 14:09:07
 */
export function programmaticCreateAd(data) {
  return request.post(API.PROGRAMMATIC_CREATE_AD, data);
}

/**
 * @description 获取任务详情
 * @param {Object} params
 * @param {String} params.task_id - 任务id
 * @author fengjin
 * @date 2021-12-15 18:36:42
 */
export function getTaskDetails(params) {
  /* return request.get(API.GET_TASK_DETAILS, {
     params,
   });*/
  return Promise.resolve(taskData)
}

/**
 * @description 单个或批量取消提交定时任务
 * @param {Object} data
 * @param {Array} data.index_list
 * @param {String} data.index_list.ad_index
 * @param {String} data.index_list.campaign_index
 * @param {String} data.task_id
 * @author fengjin
 * @date 2021-12-16 15:47:33
 */
export function cancelSubmitTask(data) {
  return request.post(API.CANCEL_SUBMIT_TASK, data);
}

/**
 * @description 删除定时任务
 * @param {Object} params
 * @param {String} params.ad_index - 广告计划下标
 * @param {String} params.campaign_index - 广告组下标
 * @param {String} params.task_id - 任务id
 * @author fengjin
 * @date 2021-12-16 16:50:31
 */
export function delSubmitTask(params) {
  return request.get(API.DEL_SUBMIT_TASK, {
    params,
  });
}

/**
 * @description 查看任务审核状态
 * @param {Object} params
 * @param {String} params.task_id - 任务id
 * @author fengjin
 * @date 2021-12-17 16:54:03
 */
export function checkTaskStatus(params) {
  return request.get(API.CHECK_TASK_STATUS, {
    params,
  });
}
